<?php
/**
 * 用户列表
 * @author pirate
 */
class Admin_UsersController extends Edm_Controller_Action {


    /* 用户列表 */
    public function indexAction () {
        $this->view->ur_here = '用户列表';
        $filter = new Zend_Filter_HtmlEntities();
        $data = array(
            'pageSize' => $this->common->defaultPageSize,
            'pageNum' => $filter->filter($this->_request->getQuery('page', 1))
        );
        if ($this->_request->isGet()) {
            $data['keywords'] = $filter->filter($this->_request->getQuery('keywords'));
        }
        $res = $this->_users->userList($data);
        $this->view->search = array('keywords' => $data['keywords']);
        $this->view->list = $res['list'];
        $this->pager->Pager($res['count'], $data['pageSize']);
        $this->view->pageResult = $this->pager->display();
        $this->view->uri = $this->common->getUrl();
    }

    /* 删除 */
    public function delAction () {
        /* 禁用视图 */
        $this->_helper->viewRenderer->setNoRender();
        $filter = new Zend_Filter_HtmlEntities();
        $user_id = $filter->filter($this->_request->get('user_id'));
        $fromUrl = $filter->filter($this->_request->get('fromurl'));
        if (!empty($user_id) && !empty($fromUrl)) {
            $this->_users->Delete($user_id) ? $this->common->msg($fromUrl, '信息删除成功！') : $this->common->msg($fromUrl, '信息删除时出现异常,删除失败！', 'Error');
        }
    }

}

